package project_model;

/**
 * TemplateMethodTest
 *
 * @author Syzer
 * @Description 模板方法模式
 * @Date 2021/7/9 16:27
 */
public class TemplateMethodTest {

    private abstract static class Template {
        public void start() {
            preStart();
            System.out.println("我执行了");
            postStart();
        }

        protected abstract void preStart();

        protected abstract void postStart();
    }

    private static class TempImpl extends Template{
        @Override
        protected void preStart() {
            System.out.println("阻塞");
        }

        @Override
        protected void postStart() {
            System.out.println("销毁");
        }
    }

    public static void main(String[] args) {
        Template temp = new TempImpl();
        temp.start();
    }
}
